#include <iostream>
#include <string>
#include <jsoncpp/json/json.h>
struct Studnet
{
    Studnet(std::string name,int age,int sex)
    :_name(name),_age(age),_sex(sex)
    {

    }
    std::string _name;
    int _age;
    int _sex;
};

int main()
{
    Studnet s1("www",18,1);

    //序列化
    Json::Value root;
    root["name"] = s1._name;
    root["age"] = s1._age;
    root["sex"] = s1._sex;
    Json::FastWriter write;
    std::string str = write.write(root);
    std::cout << str << std::endl;

    //反序列化
    Json::Value root2;
    Json::Reader read;
    read.parse(str,root2);
    s1._name = root2["name"].asCString();
    s1._age = root2["age"].asInt();
    s1._sex = root2["sex"].asInt();

    std::cout << s1._name << s1._age << s1._sex << std::endl;
}